package com.test.Annotation;

import java.lang.reflect.Field;

/**
 * ${DESCRIPTION}
 *
 * @author muxiaoyu
 * @create 2017/06/02 14:14
 **/
public class Apple {
    @FruitName(value = "Apple iPhone 7S Plus Golden")
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Apple{" +
                "name='" + name + '\'' +
                '}';
    }

    public Apple(String name) {
        this.name = name;
    }

    public Apple() {
    }

    public static void main(String[] args) {
        Class clazz = Apple.class;
        Field[] declaredFields = clazz.getDeclaredFields();
        for (Field declaredField : declaredFields) {
            if (declaredField.isAnnotationPresent(FruitName.class)) {
                FruitName fruitName = declaredField.getAnnotation(FruitName.class);
                System.out.println(fruitName.value());
            }
        }
    }
}
